package com.ext.aic.ui;

import android.annotation.SuppressLint;
import android.content.pm.ActivityInfo;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.FragmentActivity;

import com.ext.aic.events.OnBundleListener;
import com.ext.aic.handler.AuthorizationHandler;
import com.ext.aic.handler.BundleHandler;
import com.gyf.immersionbar.ImmersionBar;

import java.io.Serializable;

public class BasePureActivity extends FragmentActivity implements OnBundleListener {

    protected AuthorizationHandler authorizationHandler = new AuthorizationHandler();
    private BundleHandler bundleHandler = new BundleHandler();
    private Bundle bundle;

    @SuppressLint("SourceLockedOrientationActivity")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        ImmersionBar.with(this)
                .statusBarDarkFont(true)
                .keyboardEnable(true)
                .init();

        bundle = bundleHandler.initBundle(this);
    }

    @Override
    public String getBundleString(String key) {
        return bundleHandler.getBundleString(bundle, key);
    }

    @Override
    public int getBundleInt(String key) {
        return bundleHandler.getBundleInt(bundle, key);
    }

    @Override
    public long getBundleLong(String key) {
        return bundleHandler.getBundleLong(bundle, key);
    }

    @Override
    public boolean getBundleBoolean(String key) {
        return bundleHandler.getBundleBoolean(bundle, key);
    }

    @Override
    public <T extends Serializable> T getSerializable(String key, Class<T> clazz) {
        return bundleHandler.getSerializable(bundle, key, clazz);
    }
}
